def seq_len(num):
    if ~num == 0:
        return 32
    curr_len, pre_len, ans = 0, 0, 1
    cycle = 0
    while num and cycle < 32:
        if num & 1 == 1:
            curr_len += 1
        else:
            if num & 2 == 1:
                pre_len = curr_len
            else:
                pre_len = 0
            curr_len = 0
        num >>= 1
        ans = max(ans, curr_len + 1 + pre_len)
        cycle += 1
    return ans


print(seq_len(0))
